package pers.elonnsu.springbootmall.exception;

/**
 * spring-boot-mall项目自定义异常枚举
 * <p>
 * 异常码结构：
 * -        -        -      --
 * 业务模块  子功能    类别    异常
 * 1**** 业务异常
 * 2**** 系统异常
 * 3**** 可复用异常
 *
 * @author Yilong Su
 */
public enum MallExceptionEnum {
    //
    NO_ENUM(10000, "没有此常量"),
    NEED_USER_NAME(11101, "用户名不能为空"),
    NEED_PASSWORD(11102, "密码不能为空"),
    NEED_LOGIN(11103, "请先进行登录"),
    NEED_ADMIN_LOGIN(11104, "需要管理员权限登录"),
    PASSWORD_TOO_SHORT(11201, "密码长度不能小于8位"),
    PASSWORD_WRONG(11202, "密码错误"),
    INSERT_FAILED(11301, "写入数据失败"),
    UPDATE_FAILED(11302, "更新数据失败"),
    DELETE_FAILED(11303, "删除数据失败"),
    MKDIR_FAILED(11304, "创建文件夹失败"),
    UPLOAD_FAILED(11305, "上传失败"),
    SYSTEM_ERROR(20000, "系统异常"),
    REQUEST_PARAM_ERROR(20001, "请求参数错误"),
    PARM_NOT_NULL(31001, "名称不能为空"),
    NAME_EXISTED(31002, "不允许重名");

    /**
     * 状态码
     */
    private final Integer code;
    /**
     * 状态信息
     */
    private final String message;

    MallExceptionEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    @Override
    public String toString() {
        return "MallExceptionEnum{" +
                "code=" + code +
                ", message='" + message + '\'' +
                '}';
    }
}
